<template>
	<view>
		<view style="display: flex;width: 750rpx;height: 122.61rpx;box-sizing: border-box;padding: 0 250rpx;justify-content: space-between;align-items: center;position: fixed;top: 0;background: #F5F5F5;z-index: 121212;">
			<view v-for="(itme,index) in leixing" :key="index" style="display: flex;flex-direction: column;align-items: center;margin-bottom: 9rpx;" @tap="add(itme,index)">
				<view style="font-size: 35rpx;" :class="indexl == index?'clc':''">{{itme}}</view>
				<view style="width: 67rpx;height: 6.65rpx;border-radius: 3.3rpx;margin-top: 9rpx;" :class="indexl == index?'clcc':'clccc'"></view>
			</view>
		</view>
		<view style="margin-bottom: 140rpx;margin-top: 122.61rpx;">
			<view v-for="(itme,index) in yishanngjia_" :key="index" style="display: flex;margin: 0 0 12.68rpx 27.77rpx;background: #FFFFFF;border-radius: 24.15rpx;width: 694.6rpx;box-sizing: border-box;padding: 25.5rpx; 20.5rpx 20.5rpx 20.5rpx;border: #D6D6D6 0.09rpx solid;" @tap.stop="tiaozhuan(itme)">
				<view>
					<image :src="itme.face_url" style="width: 170rpx;height: 170rpx;border-radius: 6.03rpx;vertical-align: middle;"></image>
				</view>
				<view style="margin-left: 20.556rpx;">
					<view style="font-size: 32rpx;color: #414141;margin-top: 10rpx;font-weight: bold;">{{itme.title}}</view>
					<view style="font-size: 28.15rpx;color: #BEBEBE;margin: 15rpx 0 8rpx 0;">{{itme.label}}</view>
					<view style="display: flex;justify-content: space-between;width: 457rpx;">
						<view>
							<text style="font-size: 22.368rpx;color: #E4605A;font-weight: bold;">￥</text>
							<text style="font-size: 35.368rpx;color: #E4605A;font-weight: bold;margin: 0 5rpx;">{{itme.map.priceList.length > 0 ? itme.map.priceList[0].price:''}}</text>
							<text style="font-size: 22.368rpx;color: #E4605A;font-weight: bold;">/节</text>
							<!-- <text style="font-size: 21.744rpx;color: #C7C7C7;margin-left: 18rpx;">￥{{itme.amout}}</text> -->
						</view>
						<view style="display: flex;">
							<view style="width: 110.83rpx;height: 50.9rpx;border-radius: 9rpx;border:0.6rpx solid #EE7B30;color: #EE7B30;font-size: 27.15rpx;margin-right: 20.52rpx;line-height: 50.9rpx;text-align: center;" @tap.stop="biaoji(itme)">编辑</view>
							<view style="width: 110.83rpx;height: 50.9rpx;border-radius: 9rpx;border:0.6rpx solid #EE7B30;color: #FFFFFF;font-size: 27.15rpx;background: #EE7B30;line-height: 50.9rpx;text-align: center;" @tap.stop="shang_xia_jia(itme)">{{index_con}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view style="position: fixed;width: 648.7rpx;height: 85.76rpx;line-height: 85.76rpx;background: #EE7B30;text-align: center;color: #FFFFFF;font-size: 29rpx;border-radius: 42.9rpx;bottom: 40rpx;left: 50.736rpx;" @tap="gotianjia">
			添加课程
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				leixing:["已上架","已下架"],
				jigou_id:"",
				num:2,
				page:1,
				indexl:0,
				yishanngjia_:[],
				xiashanngjia_:[],
				index:"我是一个得长号培训机构",
				index_con:"下架"
			}
		},
		methods:{
			tiaozhuan(itme){
				uni.navigateTo({
					 url: '/pages/World/classChannel/classChannel?num=' + encodeURIComponent(JSON.stringify(itme))
				})
			},
			biaoji(itme){
			   uni.navigateTo({
				   url:"/pages/Friend/setNewFriend/setNewFriend?num=" + encodeURIComponent(JSON.stringify(itme))
			   })
			},
		async	shang_xia_jia(itme){
				let me = this
				let id = itme.id
				let sta = ""
				if(me.index_con == "下架"){
					sta = 1
				}else if(me.index_con == "上架"){
					sta = 2
				}
				const res = await me.$myRequest({
					url:"/masterSetPrice/update",
					methed:"post",
					data:{
						id:id,
						status:sta
					},
					header:{
						'content-type':'application/json'
					}
				})
				if(res.code == 0){
					uni.showToast({
						title: me.index_con + res.message,
						icon:"none"
					})
					if(me.index_con == "下架"){
						this.num = 2
						this.yishangjia()
					}else{
						this.num = 1
						this.yishangjia()
					}
				}
			},
			add(itme,index){
				this.indexl = index
				if(itme == "已下架"){
					this.index_con = "上架"
					this.num = 1
					this.yishangjia()
				}else{
					this.num = 2
					this.yishangjia()
					this.index_con = "下架"
				}
				uni.pageScrollTo({
		　　　　　　scrollTop: 0
		　　　　})
			},
			gotianjia(){
				uni.navigateTo({
					url:"/pages/World/myCollection/myCollection"
				})
			},
		async	yishangjia(){
				let me = this
				const res = await me.$myRequest({
					url:"/masterSetPrice/queryCourseListPage",
					data:{
						mechanism_id:me.jigou_id,
						type:"mechanism_offline",
						status:me.num,
						currentPage:me.page,
						pageSize:20
					},
					header:{
						'content-type':'application/json' 
					}
				})
				me.yishanngjia_ = []
				if(res.code == 0){
					me.yishanngjia_ = res.data
				}
			}
		},
		onLoad() {
			try{
				this.jigou_id =  uni.getStorageSync('userif_list').mechanism_id
			}catch(e){}
			this.yishangjia()
		},
		onShow() {
			
		}
	}
</script>
<style lang="scss" scoped>
	.clc{
		color: #EE7B30;
	}
	.clcc{
		background: #EE7B30;
	}
	.clccc{
		background:transparent;
	}
</style>